/**
 * Rewrite Roman numerals in standard form.
 */

#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include "euler/roman_numeral.hpp"
#include "euler.h"

BEGIN_PROBLEM(89, solve_problem_89)
	PROBLEM_TITLE("Develop a method to express Roman numerals in minimal form")
	PROBLEM_ANSWER("743")
	PROBLEM_DIFFICULTY(1)
	PROBLEM_FUN_LEVEL(1)
	PROBLEM_TIME_COMPLEXITY("N")
	PROBLEM_SPACE_COMPLEXITY("1")
END_PROBLEM()

static void solve_problem_89()
{
	std::fstream fs("input/roman.txt");
	std::string input, output;
	int savings = 0;
	while (fs >> input)
	{
		int n;
		std::istringstream sin(input);
		sin >> roman(n);
		std::ostringstream sout;
		sout << roman(n);
		output = sout.str();
		savings += (int)(input.size() - output.size());
	}
	std::cout << savings << std::endl;
}
